package 力扣日常刷题.木22二月.第06天212;

/**
 * @author 帅小伙
 * @date 2022/2/12
 * @description
 */
public class Demo42贪心盛最多水的容器 {

    public int maxArea(int[] height) {
        int l = 0;
        int r = height.length - 1;
        int ans = 0;
        while(l < r){
            ans = Math.max(ans,(r - l) * Math.min(height[l], height[r]));
            if(height[l] > height[r]) r --;
            else l ++;
        }
        return ans;
    }

}
